package com.openingedu.mba.screen.activity.practice;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.lurencun.android.support.ui.BackUIActivity;
import com.lurencun.android.toolkit.util.ActivitySwitcher;
import com.openingedu.mba.R;
import com.openingedu.mba.common.AppSetting;

/**
 * 练习前欢迎界面
 * @author unidw
 *
 */
public class WelcomeActivity extends BackUIActivity {

	private Context mContext;
	private String title;
	private String targetName;
	@Override
	protected void onCreateEx(Bundle savedInstanceState) {
		mContext = this;
		Intent intent = getIntent();
		title = intent.getStringExtra(AppSetting.MENU_TITLE);
		int value = intent.getIntExtra(AppSetting.MENU_VALUE, 0);
		targetName = intent.getStringExtra(AppSetting.MENU_TARGETNAME);
		// 设置标题
		TextView titleView = (TextView) findViewById(R.id.app_title);
		titleView.setText(title);
		TextView welcomeContent = (TextView) findViewById(R.id.welcome_content);
		Button welcomeBtn = (Button) findViewById(R.id.welcome_btn);
		// 设置内容
		// 随机练习
		if (value == 0) {
			welcomeContent.setText(getResources().getText(R.string.random_pratice_desc));
		}
		else {
			
		}
		
		welcomeBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String className = mContext.getPackageName() + targetName;
				Class tartClazz = null;
				try {
					tartClazz = Class.forName(className);
				} catch (ClassNotFoundException e) {
				}
				
				String[] keys = new String[] { AppSetting.MENU_TITLE};
				Object[] vals = new Object[] { title};
				ActivitySwitcher.switchTo(WelcomeActivity.this, tartClazz, keys, vals);
				finish();
			}
		});
	}
	
	@Override
	protected int getBackButtonResId() {
		return R.id.back_button;
	}

	@Override
	protected int getContentViewLayoutId() {
		return R.layout.practice_welcome;
	}

	@Override
	protected boolean isConfirmBack() {
		return false;
	}

}
